home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / utility / blrmu13.zip / BCR.ASM next >
Assembly Source File  |  1991-10-21  |  4KB  |  167 lines

  1. page ,132
  2. title bcr ( batch C R ) as of 10/21/91 - 11:35 am
  3. ;*-------------------------------------------------
  4. ;
  5. ;        Batch Carriage Return
  6. ;
  7. ;        does multiple CR, LF's from batch files
  8. ;        ( usually for spacing purposes )
  9. ;
  10. ;        syntax : bcr nn ( nn = 1 - 25 )
  11. ;
  12. ;   error checking:
  13. ;
  14. ;        if n = 1 - 25, then n is ok
  15. ;
  16. ;        if n < 1 or n > 25, then n is set to 1
  17. ;
  18. ;        if no n, the n is set to 1
  19. ;
  20. ;*-------------------------------------------------
  21.          include vdomac.lib
  22. ;*-------------------------------------------------
  23.          .model small
  24.          .code
  25. ;
  26.          org   128
  27. ;
  28. pl       db    0            ; parm len = space + amt ( n = 2, nn = 3 )
  29.          db    0            ; space
  30. amt      db    0,0          ; C R amount
  31. ;
  32.          dd    0
  33. mbtf     dw    0            ; multiply byte temp field
  34. tbf      dw    0            ; temp binary field
  35. stcsl    db    0            ; save the crsr start line
  36. stcel    db    0            ; save the crsr end line
  37. ;
  38.          org   256
  39. ;
  40. bcr:
  41. ;
  42.          cmp   pl,0         ; no parm
  43.          je    ma1          ; if so, make 1
  44. ;
  45.          cmp  pl,2          ; 1 digit + space ?
  46.          je   pod           ; if so, process one digit
  47. ;
  48.          cmp  pl,3          ; 2 digits + space ?
  49.          jne  ma1           ; if not, make amt 1
  50. ;
  51.          call ptd           ; call process two digits
  52. ;
  53. ;        validate amt between 1 - 25
  54. ;
  55.          cmp   cx,1         ; amt = 1 ?
  56.          jl    ma1          ; if LT, make amt 1
  57. ;
  58.          cmp   cx,25        ; amt = 25 ?
  59.          jg    ma1          ; if GT, make amt 1
  60. ;
  61.          jmp   sc           ; ok, do the loop
  62. ;
  63. ;   process one digit
  64. ;
  65. pod:
  66.          cld                ; forward
  67.          lea   si,amt       ; ptr to amt
  68.          lodsb              ; put it in al
  69.          and   al,15        ; make ascii binary
  70.          mov   ch,0         ; clear ch
  71.          mov   cl,al        ; mov al to cl
  72. ;
  73. ;        validate amt between 1 - 9
  74. ;
  75.          cmp   cl,1         ; amt = 1 ?
  76.          jl    ma1          ; if LT, make amt 1
  77. ;
  78.          cmp   cl,9         ; amt = 9 ?
  79.          jg    ma1          ; if GT, make amt 1
  80. ;
  81.          jmp   sc           ; ok, carry on
  82. ;
  83. ;  make amt 1
  84. ;
  85. ma1:
  86.          mov   cl,1
  87. ;
  88. ;   save cursor
  89. ;
  90. sc:
  91.          csrsv              ; crsr save
  92.          csroff             ; crsr off
  93. ;
  94. ;   CR, LF loop
  95. ;
  96. cll:
  97. ;
  98.          mov   dl,13        ; set CR
  99.          mov   ah,2         ; display output
  100.          int   33           ; DOS F C
  101. ;
  102.          mov   dl,10        ; set LF
  103.          mov   ah,2         ; display output
  104.          int   33           ; DOS F C
  105.  
  106.          loop  cll          ; nn times
  107. ;
  108.          csron              ; crsr on
  109. ;
  110.          mov   al,0         ; set cond code to 0
  111.          mov   ah,76        ; exit
  112.          int   33
  113. ;
  114. ;*------------------------
  115. ;*  process two digits
  116. ;*------------------------
  117. ptd      proc  near
  118. ;
  119.          lea   si,amt       ; ptr to input
  120.          lea   di,tbf       ; ptr to ouput
  121.          mov   bx,2         ; len of input
  122.          mov   tbf,0        ; clear result
  123.          call  catb
  124.          mov   cx,tbf       ; mov result to cx
  125.          ret
  126. ;
  127. ptd      endp
  128. ;
  129. ;*------------------------------
  130. ;*   convert ascii to binary
  131. ;*------------------------------
  132. ;*------------------------------
  133. ;* converts an ascii decimal
  134. ;* number pointed to by si,
  135. ;* to a dw binary field pointed
  136. ;* to by di,
  137. ;* with the input field width
  138. ;* in bx,
  139. ;* and using a dw multiply
  140. ;* temporary field named mbtf
  141. ;*------------------------------
  142. catb     proc  near
  143. ;
  144.          push  ax
  145.          push  cx
  146.          mov   cx,10
  147.          mov   mbtf,1
  148.          sub   si,1
  149. ;
  150. catbl:
  151.          mov   al,[si+bx]
  152.          and   ax,15
  153.          mul   mbtf
  154.          add   [di],ax
  155.          mov   ax,mbtf
  156.          mul   cx
  157.          mov   mbtf,ax
  158.          dec   bx
  159.          jnz   catbl
  160.          pop   cx
  161.          pop   ax
  162.          ret
  163. ;
  164. catb     endp
  165. ;
  166.          end   bcr
  167.